﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="UTF-8" name="viewport" content="width=device-width" />
    <title>登录 | 川谷数据字典</title>
    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="~/css/common.css" rel="stylesheet" />
    <link href="~/css/login.css" rel="stylesheet" />
</head>
<body>
<div class="login_bg clearfix">
    <div class="row height100">
        <div class="login-banner height100  col-lg-9 col-md-9 col-sm-9">
            <h3 class="login-title" style="display: block"><img style="width: 140px" src="~/resources/images/logo.png" />川谷金融科技&nbsp;•&nbsp;数据字典</h3>
            <div class="login-info">
                <p>私募数据库&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp; 智能配置算法</p>
                <p>覆盖全面&nbsp;&nbsp;|&nbsp;&nbsp;准确及时&nbsp;&nbsp;|&nbsp;&nbsp;特色指标</p>
            </div>
        </div>
        <div class="login-right height100 col-lg-3 col-md-3 col-sm-3">
            <p class="user-tit text-center">用户登录</p>
            <div class="loginTabs">
                <div class="inputBox">
                    <span class="user_name_img pull-left user_img1"></span>
                    <input type="text" name="txt_login_name" class="inputBox_input" id="txt_login_name" placeholder="请输入用户名" style="" autocomplete="new-password">
                </div>
                <div class="inputBox" style="margin-bottom: 34px;">
                    <span class="user_name_img pull-left user_img2"></span>
                    <input type="password" name="txt_login_pwd" class="inputBox_input" id="txt_login_pwd" placeholder="请输入密码" style="" autocomplete="new-password">
                </div>
                <div class="btn_con">
                    <p>
                        <input type="checkbox" id="remember" /> <label for="remember">记住密码</label>
                    </p>
                    <div class="btn_box clearfix">
                        <button class="login_btn" id="btn_login">登录</button>
                    </div>
                </div>

            </div>
            <div class="tel_num">
                如有疑问请致电川谷金融科技：4008-717-988
            </div>
        </div>
    </div>
</div>

<!--登录错误提示模态窗-->
    <div id="loginErrorModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">错误提示</h4>
                </div>
                <div class="modal-body">
                    <p style="font-size:large">用户名或密码错误!</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!--服务器错误提示框-->
<div id="serviceErrorModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">错误提示</h4>
            </div>
            <div class="modal-body">
                <p style="font-size:large">无法连接到服务器,请稍后再试!</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

</body>
</html>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdn.bootcss.com/js-cookie/latest/js.cookie.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        get_remember();
    });

    function get_remember() {
        var name = Cookies.get('name');
        var pwd = Cookies.get('pwd');
        if (name!=null && pwd!=null && name.length > 0 && pwd.length > 0) {
            $("#txt_login_name").val(name);
            $("#txt_login_pwd").val(pwd);
            $("#remember").prop('checked',true);
        }
    }

    //登录按钮执行事件
    $("#btn_login").click(function () {
        var name = $("#txt_login_name").val();
        var pwd = $("#txt_login_pwd").val();
        var remember = $("#remember").is(':checked');
        if (name.length < 1 || pwd.length < 1) {
            $('#loginErrorModal').modal('show');
        } else {
            $.ajax({
                url: '/Home/CheckLogin/',
                type:'post',
                dataType:'json',
                data: {
                    name: name,
                    pwd: pwd,
                    remember:remember
                },
                success: function (data) {
                    if (data) {
                        //登录成功跳转首页
                        window.location.href = '/Home/Index';
                    } else {
                        $('#loginErrorModal').modal('show');
                    }
                },
                error: function () {
                    $('#serviceErrorModal').modal('show');
                }
            });
        }
    });
</script>

